package com.droidclaimsurveyor.dal;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;


public class SurveyorDBHelper extends SQLiteOpenHelper {
	public static final String DATABASE_TABLE 		= "surveyor";
	public static final String DATABASE_NAME 		= "droidclaim.db";
	public static final int DATABASE_VERSION 		= 1;

	public static final String KEY_ID 				= "id";
	public static final String KEY_DB_SERVER_ID 	= "serverdbid";	
	public static final String KEY_SURVEYOR_ID 		= "surveyorid";
	public static final String KEY_NAME 			= "name";
	public static final String KEY_SURNAME 			= "surname";
	public static final String KEY_MOBILE 			= "mobile";
	public static final String KEY_EMAIL 			= "email";
	public static final String KEY_IMG_PATH 		= "imgPath";
	public static final String KEY_STATUS			= "status";

	private final String DATABASE_CREATE 		= "create table " + 
			DATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " +
			KEY_DB_SERVER_ID + " integer, " +
			KEY_SURVEYOR_ID + " varchar(64), " + 
			KEY_NAME + " varchar(64), " + 
			KEY_SURNAME + " varchar(64), " + 
			KEY_MOBILE + " varchar(16), " + 
			KEY_EMAIL + " varchar(256), " + 
			KEY_IMG_PATH + " varchar(512), " + 
			KEY_STATUS + " integer );";
	
	public SurveyorDBHelper(Context context, String name,CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);	
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// drop table if exist
		db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
        // Create a new one.
        onCreate(db);
	}
}